﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using bt1.DTO;

namespace bt1
{
    public partial class Form1 : Form
    {
        private DataProvider _dataProvider;

        public Form1()
        {
            InitializeComponent();
            _dataProvider = new DataProvider();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            LoadSanPham();
        }

        private void LoadSanPham()
        {
            BUS.SanPhamBUS spBUS = new BUS.SanPhamBUS();
            dtgv_sanpham.DataSource = spBUS.LayDS();
        }

        private void bt_them_Click(object sender, EventArgs e)
        {
            SanPhamDTO spDTO = new SanPhamDTO();
            spDTO.Ten = tb_tensp.Text;
            spDTO.Gia = float.Parse(tb_gia.Text);
            spDTO.SoLuongTon = float.Parse(tb_soluongton.Text);
            BUS.SanPhamBUS spBUS = new BUS.SanPhamBUS();
            spBUS.ThemSanPham(spDTO);
            LoadSanPham();
        }
    }
}
